package com.example.demo.gangOfFour_design.strategy_celue;

import com.example.demo.gangOfFour_design.strategy_celue.calc.CountCalc;
import com.example.demo.gangOfFour_design.strategy_celue.context.BaseContext;
import com.example.demo.gangOfFour_design.strategy_celue.context.SuperContext;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @Author dbin
 * @Date 2020/1/8
 **/
@RestController
public class BaseAndSuperTest {

    @Autowired
    private SuperContext superContext;

    public static void main(String[] args) {
        one();
    }

    private static void one(){
        BaseContext context;

        /**
         * 加策略
         */
        context = new BaseContext(new CountCalc());

        /**
         * 减策略
         */
        //context = new BaseContext(new SubtractCalc());

    }

    @RequestMapping("/strategy")
    private String two(String type,int i, int j){
       return "结果："+superContext.doAction(type, i, j);
    }
}
